Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Baro:add driver for the SPA06 #27905

Merged
merged 3 commits into from
Sep 11, 2024

Conversation

radiolinkW
Copy link
Contributor

The SPA06 is a high resolution low noise barometer pin-to-pin compatible with the SPL06.
I have been flight testing this baro on RadiolinkPIX6 and driver it seems to work well.
Here is the datasheet: SPA06-003_datasheet.pdf

@peterbarker
Copy link
Contributor

Needs to compile

This looks very similar to the SPL06 driver.

This looks like we should be re-using the SPLP06 driver for the SPA, particularly if they can be distinguished by their WHOAMI registers or some other fingerprinting we can do.

We seriously can't afford to copy a driver sideways - we're fast running out of flash on boards, and baros make their way into a lot of boards.

Can you think about whether it would be possible to augment the SPL driver, please?

I'm happy to take this to a DevCall to see if other devs disagree, but I don't think they will.

@radiolinkW
Copy link
Contributor Author

radiolinkW commented Aug 26, 2024

Needs to compile

This looks very similar to the SPL06 driver.

This looks like we should be re-using the SPLP06 driver for the SPA, particularly if they can be distinguished by their WHOAMI registers or some other fingerprinting we can do.

We seriously can't afford to copy a driver sideways - we're fast running out of flash on boards, and baros make their way into a lot of boards.

Can you think about whether it would be possible to augment the SPL driver, please?

I'm happy to take this to a DevCall to see if other devs disagree, but I don't think they will.

I also think it should be made into a driver, but the class name should not be SPL06.
What do you think the class name should be?SPX06?So the SPL06 driver needs to be rewritten.

@peterbarker
Copy link
Contributor

Needs to compile
This looks very similar to the SPL06 driver.
This looks like we should be re-using the SPLP06 driver for the SPA, particularly if they can be distinguished by their WHOAMI registers or some other fingerprinting we can do.
We seriously can't afford to copy a driver sideways - we're fast running out of flash on boards, and baros make their way into a lot of boards.
Can you think about whether it would be possible to augment the SPL driver, please?
I'm happy to take this to a DevCall to see if other devs disagree, but I don't think they will.

I also think it should be made into a driver, but the class name should not be SPL06. What do you think the class name should be?SPX06?So the SPL06 driver needs to be rewritten.

Yes indeed, you could rename SPL06 to SPx06 (lower-case x) and only after creating a commit for that adjust it to support the SPA06

@peterbarker
Copy link
Contributor

To be clear, if you rename a file, to it in a completely separate commit to everything else, including adjusting #includes. This ensures the history on the file is preserved.

@radiolinkW
Copy link
Contributor Author

To be clear, if you rename a file, to it in a completely separate commit to everything else, including adjusting #includes. This ensures the history on the file is preserved.

@peterbarker The SPA06 and SPL06 baro have been merged into an SPx06 driver and tested for narmal flight on the latest Copter4.5 branch.

@radiolinkW radiolinkW force-pushed the drivers/SPA06_baro branch 2 times, most recently from f3a351f to c4dcbba Compare August 29, 2024 04:08
Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review only.

This is looking good. I might look at pulling out the renaming into a separate PR as, based on your work here, re-using the same code for the two devices it viable.

libraries/AP_Baro/AP_Baro_SPx06.h Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.h Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPx06.cpp Outdated Show resolved Hide resolved
@Hwurzburg
Copy link
Collaborator

does this need an extract_features.py update or will a REGEX catch the change?

@radiolinkW
Copy link
Contributor Author

does this need an extract_features.py update or will a REGEX catch the change?

It should be updated, I replaced everything related to SPL06 with SPx06.

@radiolinkW
Copy link
Contributor Author

Partial review only.

This is looking good. I might look at pulling out the renaming into a separate PR as, based on your work here, re-using the same code for the two devices it viable.

Updated and committed.

@peterbarker
Copy link
Contributor

@radiolinkW I've extracted those rename commits over here: https://github.com/ArduPilot/ardupilot/pull/27992/commits - I should be able to get that in soon which will let me take this to DevCallEU tomorrow for a merge, hopefully.

@radiolinkW
Copy link
Contributor Author

@radiolinkW I've extracted those rename commits over here: https://github.com/ArduPilot/ardupilot/pull/27992/commits - I should be able to get that in soon which will let me take this to DevCallEU tomorrow for a merge, hopefully.

Thanks, won't the other three commits be merged?

@peterbarker
Copy link
Contributor

@radiolinkW I've extracted those rename commits over here: https://github.com/ArduPilot/ardupilot/pull/27992/commits - I should be able to get that in soon which will let me take this to DevCallEU tomorrow for a merge, hopefully.

Thanks, won't the other three commits be merged?

Oh yes - but we'll get the other ones in first. That will make this one much easier to review on a DevCall to get it merged.

@peterbarker
Copy link
Contributor

I also think it should be made into a driver, but the class name should not be SPL06. What do you think the class name should be?SPX06?So the SPL06 driver needs to be rewritten.

Unfortunately we both got this wrong, as it turns out.

tridge was very resistant to renaming this driver, and gave several good reasons why it would be a bad idea - mostly breaking things out-of-tree. He pointed out several places in our codebase where we simply add comments indicating what devices a driver handles.

I've taken the liberty of removing the rename of the files and the rename of the class commits from your branch and fixing the conflicts

I've force-pushed over your branch here.

If you're happy to proceed from this point I'll leave a review so we can get this merged... also, testing that I haven't broken anything when I resolved those conflicts would be a good idea!

@radiolinkW
Copy link
Contributor Author

I also think it should be made into a driver, but the class name should not be SPL06. What do you think the class name should be?SPX06?So the SPL06 driver needs to be rewritten.

Unfortunately we both got this wrong, as it turns out.

tridge was very resistant to renaming this driver, and gave several good reasons why it would be a bad idea - mostly breaking things out-of-tree. He pointed out several places in our codebase where we simply add comments indicating what devices a driver handles.

I've taken the liberty of removing the rename of the files and the rename of the class commits from your branch and fixing the conflicts

I've force-pushed over your branch here.

If you're happy to proceed from this point I'll leave a review so we can get this merged... also, testing that I haven't broken anything when I resolved those conflicts would be a good idea!

That's also good, there won't be much change.

But I didn't see a comment in the top of the SPL06 driver saying it supports SPA06 as well, also, RadiolinkPIX6 does not enable Background mode by default.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested an SPL06 device to ensure it continues to function normally after these changes?

Please outline the advantages of using the "background" mode of the SPA06...

libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
libraries/AP_Baro/AP_Baro_SPL06.cpp Outdated Show resolved Hide resolved
@radiolinkW
Copy link
Contributor Author

Updated and committed.

@radiolinkW
Copy link
Contributor Author

Have you tested an SPL06 device to ensure it continues to function normally after these changes?

Please outline the advantages of using the "background" mode of the SPA06...

The latest commit has been tested for narmal flight on the latest Copter4.5 branch.

Background mode only measures continuously, without manually enabling measurements periodically.

@peterbarker
Copy link
Contributor

@radiolinkW have you tested a device with an SPL06 in it?

I'm marking this for discussion DevCallEU, and that question will be asked :-)

@peterbarker
Copy link
Contributor

peterbarker commented Sep 11, 2024

I've tested this on a MatekH7A6 which has an SPL06 baro on it - no functionality change I could see.

@radiolinkW
Copy link
Contributor Author

radiolinkW commented Sep 11, 2024

@radiolinkW have you tested a device with an SPL06 in it?

I'm marking this for discussion DevCallEU, and that question will be asked :-)

Tested on RadiolinkPIX6 with SPA06 and flying normally.

@peterbarker peterbarker merged commit 66a2788 into ArduPilot:master Sep 11, 2024
94 checks passed
@peterbarker
Copy link
Contributor

Merged, thanks!

@radiolinkW
Copy link
Contributor Author

Thanks! @peterbarker @tridge
Why only merge into the master branch instead of other release branches,such as the Copter 4.5 branch?
This has been merged for a long time.

@menschel
Copy link
Contributor

Hello, does this change also influence the SPL001 update rate?

I have Baro-0 /Baro-4 i.e. Baro Bad Health issues on a plane while circling over a field for 30minutes and I believe it is due to the baro having the same value for 2 seconds.

Meaning to ask, does it make sense to test with AP4.6Beta1 or write an Issue Report directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants